package com.itheima.service.impl;

import com.itheima.domain.User;
import com.itheima.domain.UserExample;
import com.itheima.mapper.UserMapper;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;

    @Override
    public User finBytemple(String telephone) {


        UserExample userExample = new UserExample();
        UserExample.Criteria criteria = userExample.createCriteria().andTelephoneEqualTo(telephone);
        List<User> users = userMapper.selectByExample(userExample);
        System.out.println(users);
        if (users != null && users.size()==1){
            System.out.println(users);
            //查询到的手机号关联的唯一用户数据
                  return users.get(0);
        }
        return null;
    }
}
